< previous page page_579 next page >

Page 579
CAUTION
If you're working with a database type other than Jet, check the Bookmarkable property of the recordset you are using to see whether bookmarks are supported before you execute any methods that depend on the bookmarks.

Using the Find Methods
You can use the Find methods on dynasets and snapshots only. You can't use Find methods on table-type recordsets. (Because the sample program was created with a table-type recordset, you can't use the Find methods in the example.) The Find methods are used to locate records that meet specified criteria. You express the criteria in the same way that you specify the Where clause of a SQL commandexcept without the Where keyword. The four Find methods are as follows:
Find Method
Action
FindFirst
Starting at the top of the recordset, finds the first record in the recordset with the specified criteria
FindNext
Starting at the current location in the recordset, finds the next record down with the specified criteria
FindPrevious
Starting at the current location in the recordset, finds the next record up with the specified criteria
FindLast
Starting at the bottom of the recordset, finds the last record in the database with the specified criteria

After the Find method is executed, check the status of the recordset's NoMatch property. If NoMatch is True, the method failed to find a record that matched the requested criteria. If NoMatch is False, the record pointer is positioned at the desired record.
tip.gif
You might want to set a bookmark prior to invoking one of the Find methods. Then, if a matching record is not found, you can return to the record that was current before the Find was attempted.

The Find methods work by scanning each record to locate the appropriate record that matches the specified criteria. The starting record and direction searched depend on which of the four Find methods you use. Depending on the size of the recordset and the criteria specified, this search operation can be somewhat lengthy. The Jet engine can optimize searches if an index is available for the search expression. If you are going to perform many searches, consider creating an index for the field or fields in the base table.
When a Find method is successful, the record pointer moves to the new record. If a Find method is not successful, the recordset's NoMatch property is set to True and the record pointer does not move. One way to use the NoMatch property is to write an If condition that checks the value.

 
< previous page page_579 next page >